set mouse=a
set history=50
set ruler
set number
set fdm=indent
set autoindent
set smartindent
set shiftwidth=4
set nobackup
set cursorline

"Create header file:"
autocmd BufNewFile *.py,*.cpp,*.sh,*.java,*.[ch] exec ":call SetTitle()"

let $author_name = "Weiyi"

func SetTitle()  
    if &filetype == 'sh'
		call setline (1,"\##################################################################################")
		call append (line ("."), "\#File Name:".expand("%:t"))
		call append (line (".")+1, "\#Author:".$author_name)
		call append (line (".")+2, "\#Created Time:".strftime("%c"))
		call append (line (".")+3, "\#Description:")
		call append (line (".")+4, "\##################################################################################")
		call append (line (".")+5, "\#!/bin/bash")
		call append (line (".")+6,"")
	elseif &filetype == 'py'
		call setline (1,"\##################################################################################")
		call append (line (".") , "\#File Name:".expand("%:t"))
		call append (line (".")+1, "\#Author:".$author_name)
        	call append (line (".")+2, "\#Created Time:".strftime("%c"))
        	call append (line (".")+3, "\#Description:")
		call append (line (".")+4, "\##################################################################################")
		call append (line (".")+5, "\#!/usr/bin/python")
		call append (line (".")+6,"")
	else
        	call setline (1,"\##################################################################################")
		call append (line ("."), "\#File Name:".expand("%:t"))
        	call append (line (".")+1, "\#Author:".$author_name)
        	call append (line (".")+2, "\#Created Time:".strftime("%c"))
        	call append (line (".")+3, "\#Description:")
        	call append (line (".")+4, "\##################################################################################")
        	call append (line (".")+5, "")
	endif
endfunc

autocmd BufNewFile * normal G

 "F3 key compile"
102 map <F3> :call CompileRunGcc()<CR>
103 func! CompileRunGcc()
104         exec "w"                                                                                                                                    
105         exec "!clear"
106         if &filetype == 'c'
107             exec "!gcc -Wall % -o %<.cout"
108             exec "!./%<.cout"
109         elseif &filetype == "cpp"
110             exec "!g++ -Wall % -o %<.cppcout"
111             exec "!./%<.cppout"
112         elseif &filetype == "java"
113             exec "!javac %"
114             exec "!java %<"
115         endif
116 endfunc

